import time


class TicToc():
    def __init__(self, msgs: str):
        self.start_time = time.time()  # 程序开始时间
        self.end_time = time.time()  # 程序开始时间
        self.msgs = msgs

    def tic(self):
        self.start_time = time.time()  # 程序开始时间

    def toc(self):
        self.end_time = time.time()  # 程序结束时间
        run_time = self.end_time - self.start_time  # 程序的运行时间，单位为秒
        print("-----------  <{}> cost [{}] ms   ---------------".format(self.msgs, run_time * 1000))
